package chabernac.gravidroid.paint;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.view.View;
import chabernac.android.draw.AbstractDrawable;
import chabernac.gravidroid.model.Structure;
import chabernac.gravidroid.model.Vector;

public class StructureDrawable extends AbstractDrawable {
	private final Structure myStructure;
	private final Paint myPaint;
	private final Vector[] myLocations;

	public StructureDrawable(Structure aStructure) {
		super();
		myStructure = aStructure;
		myPaint = new Paint();
		myPaint.setColor(aStructure.getColor());
		myPaint.setStrokeWidth(20);
		myLocations = aStructure.getPoints();
	}

	@Override
	public void paint(Canvas aCanvas, View aView) {
		myPaint.setColor(myStructure.getColor());
		
		int j = 0;
		for(int i=0;i<myLocations.length;i++){
		    j = i + 1;
		    if(j == myLocations.length) j = 0;
		    aCanvas.drawLine( myLocations[i].x, myLocations[i].y,myLocations[j].x, myLocations[j].y, myPaint);
		}
//		for (LinearMass theLinearMass : myStructure.getLinearMasses()) {
//			aCanvas.drawLine(theLinearMass.getMass1().location.x, theLinearMass.getMass1().location.y, theLinearMass.getMass2().location.x,
//					theLinearMass.getMass2().location.y, myPaint);
//		}
	}

}
